//
//  ThirdViewController.m
//  Day_21 夜间模式
//
//  Created by dllo on 15/11/6.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "ThirdViewController.h"

@interface ThirdViewController ()

@end

@implementation ThirdViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(100, 100, 100, 100);
    button.backgroundColor = [UIColor blueColor];
    [self.view addSubview:button];
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    
 
    
}

- (void)buttonAction:(UIButton *)btn{
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"whiteOrBlack"] isEqualToString:@"0"]) {
        [[NSUserDefaults standardUserDefaults] setObject:@"1" forKey:@"whiteOrBlack"];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"changeColor" object:[UIColor blackColor]];
    }else{
        [[NSUserDefaults standardUserDefaults] setObject:@"0" forKey:@"whiteOrBlack"];
        [[NSNotificationCenter defaultCenter]postNotificationName:@"changeColor" object:[UIColor whiteColor]];
    }
    btn.selected = !btn.selected;
    
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
